home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 3.iso
/
dist
/
fw_sharity.idb
/
etc
/
init.d
/
fw_sharity.z
/
fw_sharity
Wrap
Text File
|
2002-07-08
|
5KB
|
184 lines
#!/bin/sh
# Name: sharity.init
# Project: Sharity
# Author: Christian Starkjohann <cs@obdev.at>
# Creation Date: 1998-08-15
#
# Modified by Stephane Rosa <srosa@domusmea.org> for SGI Irix
# September 2001 srosa/SGI
#
# Tabsize: 4
# Copyright: (c) 1999 by Christian Starkjohann, all rights reserved.
# For details of the license see the file doc/License.txt.
# This Revision: $Id: sharity.init,v 1.20 2002/05/06 15:06:13 cs Exp $
# RedHat information for the chkconfig/ntsysv tools:
# chkconfig: 2345 65 20
# description: Sharity is a client for the Microsoft networking protocol CIFS.
# General Description:
# This script starts or stops the sharityd daemon. It is suitable to be
# called from a startup directory. For most systems it is sufficient to
# make a link from this file into the startup directory.
#
# Arguments:
# start start the daemon
# stop shutdown the daemon
#
# If called with no arguments, the daemon is started.
SHARITY=/usr/freeware
SERVER=${SHARITY}/sbin/sharityd
CLIENT=${SHARITY}/bin/sharity
PIDFILE=${SHARITY}/var/sharity.pid
MOUNTDIR=${SHARITY}/var/mount
COREDIR=${SHARITY}/var
CONFIG=${SHARITY}/etc/sharity.cfg
IS_ON=/etc/chkconfig
nicevalue="-5"
if $IS_ON verbose
then
ECHO="/bin/echo"
else
ECHO=":"
fi
if test $# -ne 0; then
what=$1
else
what=start
fi
whereis()
{
echo $PATH | tr ':' '\012' | {
while read path; do
if [ -x "$path/$1" ]; then
echo "$path/$1"
break
fi
done
}
}
# We need to detect HP-UX because renice needs the '-n' flag there.
# We can't use uname directly because it does not exist on all platforms.
# The same seems to be true for the IRIX 6.x 'renice' command.
uname="`whereis uname`"
renice=renice
renicep="-p"
if [ -n "$uname" ]; then
osname="`$uname -s`"
if [ "$osname" = HP-UX ]; then
renice="renice -n"
fi
if [ "$osname" = AIX ]; then
renice="renice -n"
renicep=""
fi
if [ "$osname" = IRIX ]; then
if expr match "`$uname -r`" '6[.].*' >/dev/null; then
renice="renice -n"
fi
fi
fi
isRunning()
{
if test -f $PIDFILE; then
# check whether process with this PID is running. Use renice and not
# kill -0 to introduce no additional incompatibilities.
pid=`cat $PIDFILE`
if $renice +0 $renicep "$pid" >/dev/null 2>&1; then
# process with pid exists -- make sure it's a sharityd
psline1=`ps -p "$pid" 2>/dev/null`
psline2=`ps "$pid" 2>/dev/null` # other variant if -p fails
psline=`echo "$psline1" "$psline2" | grep sharityd`
if [ -n "$psline" ]; then
echo "yes"
fi
fi
fi
}
case "$what" in
start)
if ! $IS_ON fw_sharity; then
exit 0
fi
$ECHO "Starting Sharity daemon:"
if [ "`isRunning`" = yes ]; then
$ECHO "Error starting: there is already an instance of the daemon running!"
$ECHO "Please stop the running daemon before you start a new one."
exit 1
fi
if [ ! -d "$MOUNTDIR" ]; then
mkdir -p "$MOUNTDIR"
fi
# delete stale automount directories:
for i in "$MOUNTDIR"/*; do
if [ -d "$i" ]; then
rmdir "$i";
fi
done
cd "$COREDIR" # create corefiles here
if [ -f "core" ]; then
mv core core.backup
mail root << EOF
Dear System Administrator,
this is a mail from your Sharity software. The Sharity daemon has
crashed and dumped core, sorry about that. Please help us (Objective
Development) to find this bug! We need the core file, which has been
backed up to ${COREDIR}/core.backup
and we need your sharityd executable, which can be found at
${SERVER}. Please compress both files
into an archive and mail it to <sharity-bugs@obdev.at>. Since core-files
and executables tend to be LARGE files, please get in contact with us
BEFORE you mail us the files; the bug may already be known or even fixed
in a newer release!
Security Note: core files may contain private data such as the content
of your files or your passwords. Please be aware of this fact when you
mail the core file.
Regards,
your Sharity software.
EOF
fi
"${SERVER}" -f "${CONFIG}"
sleep 1 # wait until pid-file is created
$renice $nicevalue $renicep "`cat $PIDFILE`"
$ECHO "done."
;;
start_msg)
$ECHO "Starting Sharity daemon:"
;;
stop)
$ECHO "Shutting down Sharity daemon: "
if [ "`isRunning`" = yes ]; then
$ECHO "unmounting... "
if "$CLIENT" umount -a -f; then
kill "`cat $PIDFILE`"
$ECHO "done."
else
$ECHO "Error unmounting, daemon not stopped."
fi
else
$ECHO "Daemon not running!"
fi
;;
stop_msg)
$ECHO "Shutting down Sharity daemon: "
;;
reload)
$ECHO "Reloading not required for Sharity."
;;
*)
$ECHO "Usage: $0 {start|stop}"
exit 1
;;
esac